package com.example.its2021606134chh.TrafficViolationModule;

import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;
import androidx.appcompat.app.AppCompatActivity;

import com.example.its2021606134chh.R;
import com.github.mikephil.charting.utils.Utils;

public class TVVideoActivity extends AppCompatActivity {

    private VideoView videoTVVideo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_t_v_video);
        //        强制横屏
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

        initView();
//        本地视频未提供，采用网络视频实现
        String uri = "https://vd2.bdstatic.com/mda-mh44p4ahr71hhp1q/1080p/cae_h264/1628134869373171596/mda-mh44p4ahr71hhp1q.mp4?v_from_s=hkapp-haokan-hnb&auth_key=1628148042-0-0-22e75efd28f19062960121359ce1adb2&bcevod_channel=searchbox_feed&pd=1&pt=3&abtest=3000186_1";
        videoTVVideo.setVideoURI(Uri.parse(uri));
        //        创建MediaController对象
        MediaController mediaController=new MediaController(this);
        //        VideoView与MediaController建立关联
        mediaController.setMediaPlayer(videoTVVideo);
        videoTVVideo.setMediaController(mediaController);
        //        让VideoView获取焦点
        videoTVVideo.requestFocus();
//        自动播放
        videoTVVideo.start();
    }


    private void initView() {
        videoTVVideo = (VideoView) findViewById(R.id.videoTVVideo);
    }
}